package com.jeeplus.modules.guide.web;

import com.google.common.collect.Lists;
import com.jeeplus.common.web.Result;
import com.jeeplus.modules.guide.model.domain.AppointmentRecord;
import com.jeeplus.modules.guide.model.query.CancelAppointment;
import com.jeeplus.modules.guide.model.query.ModAppointment;
import com.jeeplus.modules.guide.model.query.ServiceOfficesQuery;
import com.jeeplus.modules.guide.model.vo.*;
import com.jeeplus.modules.guide.service.AppointmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * ClassName: AppointmentGuideController
 * Function:  预约指南
 * Date:      2021/6/1 11:41
 *
 * @author hanKongbin
 * version    V1.0
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/gx/guide")
public class AppointmentGuideController {

    private final AppointmentService appointmentService;
    @PostMapping("/serviceOffices")
    public Result<ServiceOffices> serviceOffices(@RequestBody ServiceOfficesQuery query) {
        return appointmentService.findServeOffices(query);
    }

    @GetMapping("/serviceTime")
    public Result<List<ServiceTime>> serviceTime(@RequestParam(value = "sysNo") String sysNo, @RequestParam(value = "businessId") String businessId) {
        return Result.succeed(appointmentService.getServiceTime(sysNo, businessId), "获取成功");
    }

    @PostMapping("/save")
    public Result<ModAppointmentOut> save(@RequestBody ModAppointment mod) {
        return appointmentService.saveAppointment(mod,false,null,null,null);
    }

    @PostMapping("/cancel")
    public Result<Boolean> cancel(@RequestBody CancelAppointment obj) {
        return Result.succeed(appointmentService.cancel(obj), "");
    }

    @GetMapping("/records")
    public Result<List<AppointmentRecordOut>> records() { 
        return Result.succeed(appointmentService.findByCardId(), "");
    }

    @GetMapping("/business-analyze")
    public Result<BusinessAnalyze> businessAnalyze(@RequestParam(value = "sysNo") String sysNo, @RequestParam(value = "businessId") String businessId) {
        return Result.succeed(appointmentService.getBusinessAnalyze(sysNo,businessId), "");
    }

    @GetMapping("/business-admin")
    public Result<BusinessAnalyze> businessAdmin() {
        return Result.succeed(appointmentService.getBusinessAdmin(), "");
    }
}
